package com.airforce.mappers;

import com.airforce.model.user_topic;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface user_topicMapper {
    @Delete({
        "delete from user_topic",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into user_topic (id, topicid, ",
        "optionContent, openid, ",
        "createtime, updatetime, ",
        "optionIndex, phase)",
        "values (#{id,jdbcType=INTEGER}, #{topicid,jdbcType=INTEGER}, ",
        "#{optioncontent,jdbcType=VARCHAR}, #{openid,jdbcType=VARCHAR}, ",
        "#{createtime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP}, ",
        "#{optionindex,jdbcType=VARCHAR}, #{phase,jdbcType=INTEGER})"
    })
    int insert(user_topic record);

    @InsertProvider(type=user_topicSqlProvider.class, method="insertSelective")
    int insertSelective(user_topic record);

    @Select({
        "select",
        "id, topicid, optionContent, openid, createtime, updatetime, optionIndex, phase",
        "from user_topic",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="topicid", property="topicid", jdbcType=JdbcType.INTEGER),
        @Result(column="optionContent", property="optioncontent", jdbcType=JdbcType.VARCHAR),
        @Result(column="openid", property="openid", jdbcType=JdbcType.VARCHAR),
        @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updatetime", property="updatetime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="optionIndex", property="optionindex", jdbcType=JdbcType.VARCHAR),
        @Result(column="phase", property="phase", jdbcType=JdbcType.INTEGER)
    })
    user_topic selectByPrimaryKey(Integer id);

    @UpdateProvider(type=user_topicSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(user_topic record);

    @Update({
        "update user_topic",
        "set topicid = #{topicid,jdbcType=INTEGER},",
          "optionContent = #{optioncontent,jdbcType=VARCHAR},",
          "openid = #{openid,jdbcType=VARCHAR},",
          "createtime = #{createtime,jdbcType=TIMESTAMP},",
          "updatetime = #{updatetime,jdbcType=TIMESTAMP},",
          "optionIndex = #{optionindex,jdbcType=VARCHAR},",
          "phase = #{phase,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(user_topic record);

    @Select("select * from  user_topic where openid=#{openid}")
    List<user_topic> selectByOpenid (@Param("openid") String openid);

    @Delete("delete from user_topic where openid=#{openid}")
    int deleteByOpenid(String openid);


}